-
Notifications
You must be signed in to change notification settings - Fork 0
FCM 푸쉬 알람 추가 #262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
FCM 푸쉬 알람 추가 #262
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…to feature/fcm-push-alarm(#240) # Conflicts: # build.gradle # src/main/java/zip/ootd/ootdzip/fcm/service/FcmService.java
Lechros
reviewed
Nov 27, 2024
| * Firebase Admin SDK의 비공개 키를 참조하여 Bearer 토큰을 발급 받습니다. | ||
| */ | ||
| private String getAccessToken() { | ||
| String firebaseConfigPath = "firebase/ootdzip-cf27f-firebase-adminsdk-iuig1-8969152a6a.json"; |
Collaborator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: 설정 파일로 분리하는게 낫지 않을까요?
Collaborator
Author
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
설정 분리 했습니다!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
변경사항
참고사항
FCM 을 이용하여 푸쉬알람 구현
FCM 토큰을 이용해서 푸쉬알람을 구현합니다. FCM 토큰의 경우 "디바이스" 를 식별할 수 있습니다. 디바이스로 식별하기에 하나의 유저는 여러개의 디바이스를 보유하고 있다면, 여러 개의 토큰을 가질 수 있습니다.
아키텍처는 아래와 같습니다.
클라이언트는 백엔드서버에 유저의 FCM 토큰 등록을 요청합니다. 최초로 토큰 등록 요청이라면 모든 알람을 허용한 상태로 설정하고, 이미 등록된 토큰이라면 토큰을 로그인상태로 설정합니다.
그리고 푸쉬 알람 요청 발생시, 요청 대상이 되는 FCM 토큰이 존재하고 알람을 허용한 상태라면 알람을 보냅니다. 여기서 백엔드는 파이어베이스에 푸쉬알람을 보내달라고 요청합니다. 그러면 파이어베이스가 토큰값을 통해 해당 기기에 푸쉬알람을 보냅니다. 이 알람은 클라이언트가 받아서 푸쉬알람을 띄웁니다.
그리고 사용자가 로그아웃하면 백엔드에서 토큰을 로그아웃 상태로 설정하여 알람을 받지 않도록 합니다. 이렇게하면 사용자가 공장초기화를 하고 기기를 팔아서 기기 주인이 바뀌어도 알람을 보내지 않습니다.